#include "Quaternion.h" 
#include "Matrix3.h"
//
namespace Euler
{
	const Quaternion Quaternion::ZERO(0.0, 0.0, 0.0, 0.0);


	const Quaternion Quaternion::IDENTITY(0.0, 0.0, 0.0, 1.0);


	void Quaternion::ToRotationMatrix( Matrix3& kRot ) const
	{
		Real fTx  = _x+_x;
		Real fTy  = _y+_y;
		Real fTz  = _z+_z;
		Real fTwx = fTx*_w;
		Real fTwy = fTy*_w;
		Real fTwz = fTz*_w;
		Real fTxx = fTx*_x;
		Real fTxy = fTy*_x;
		Real fTxz = fTz*_x;
		Real fTyy = fTy*_y;
		Real fTyz = fTz*_y;
		Real fTzz = fTz*_z;

		kRot[0][0] = 1.0f-(fTyy+fTzz);
		kRot[0][1] = fTxy-fTwz;
		kRot[0][2] = fTxz+fTwy;
		kRot[1][0] = fTxy+fTwz;
		kRot[1][1] = 1.0f-(fTxx+fTzz);
		kRot[1][2] = fTyz-fTwx;
		kRot[2][0] = fTxz-fTwy;
		kRot[2][1] = fTyz+fTwx;
		kRot[2][2] = 1.0f-(fTxx+fTyy);
	}
}